/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.sadhar.sipp.tagihan;
import java.util.List;
import java.util.Map;

import org.sadhar.errhandler.ClassAntiNull;
import org.sadhar.sia.framework.ClassApplicationModule;
import org.sadhar.sipp.posbiaya.PosBiaya;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Window;
/**
 *
 * @author Yohan Hardinugroho
 */
public class TagihanOnRencanaPendapatanUangKemahasiswaanPopupWnd extends ClassApplicationModule {

    private Textbox txtboxJenisTagihanSearch;
    private Listbox lstboxJenisTagihan;
    private TagihanDAO tagihanDAO;
    
    public TagihanOnRencanaPendapatanUangKemahasiswaanPopupWnd() {
	tagihanDAO = new TagihanDAOImpl();
    }


    public void onCreate() throws Exception {
        txtboxJenisTagihanSearch = (Textbox) getFellow("txtboxJenisTagihanSearch");
        lstboxJenisTagihan = (Listbox) getFellow ("lstboxJenisTagihan");
        load();
    }
    
    public void load() throws Exception {
	lstboxJenisTagihan.getItems().clear();
        int no = 1;
        List<Map> listResult = tagihanDAO.listByNamaTagih(txtboxJenisTagihanSearch.getValue());
        for(Map m: listResult){
            Listitem item = new Listitem();
            item.setValue(m);
            item.appendChild(new Listcell("" + no++));  
            item.appendChild(new Listcell(ClassAntiNull.AntiNullString(m.get("nama_tagih"))));
            lstboxJenisTagihan.appendChild(item);
        }
    }
    //txtboxIdJenisTagihan
    //txtboxJenisTagihanSearch

      public void lstboxJenisTagihanOnSelect() throws Exception {
        Window windowProduct = (Window) (Window) this.getRoot().getFellow("contentDiv").getFirstChild();
        Textbox txtboxJenisTagihanSearch = (Textbox)windowProduct.getFellow("txtboxJenisTagihanSearch");
        Textbox txtboxIdJenisTagihan = (Textbox)windowProduct.getFellow("txtboxIdJenisTagihan");
        Map m = (Map) lstboxJenisTagihan.getSelectedItem().getValue();
        txtboxJenisTagihanSearch.setValue(ClassAntiNull.AntiNullString(m.get("nama_tagih")));
        txtboxIdJenisTagihan.setValue(ClassAntiNull.AntiNullString(m.get("Kd_tagih")));
        this.detach();
    }
}
 